


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html id="htmlId">
<head>
  <title>Coverage Report :: AbstractPhasePlugin</title>
  <style type="text/css">
    @import "../../.css/coverage.css";
  </style>
</head>

<body>
<div class="header"></div>

<div class="content">
<div class="breadCrumbs">
    [ <a href="../../index.html">all classes</a> ]
    [ <a href="../index.html">at.schauer.gregor.vienna.serializer.plugin</a> ]
</div>

<h1>Coverage Summary for Class: AbstractPhasePlugin (at.schauer.gregor.vienna.serializer.plugin)</h1>

<table class="coverageStats">

<tr>
  <th class="name">Class</th>
<th class="coverageStat 
">
  Method, %
</th>
<th class="coverageStat 
">
  Line, %
</th>
</tr>
<tr>
  <td class="name">AbstractPhasePlugin</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (9/ 9)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (13/ 13)
  </span>
</td>
</tr>
  <tr>
    <td class="name">AbstractPhasePlugin$Phase</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (2/ 2)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (2/ 2)
  </span>
</td>
  </tr>
<tr>
  <td class="name"><strong>total</strong></td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (11/ 11)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (15/ 15)
  </span>
</td>
</tr>
</table>

<br/>
<br/>


<div class="sourceCode"><i>1</i>&nbsp;/*
<i>2</i>&nbsp; * Copyright 2012 Gregor Schauer
<i>3</i>&nbsp; *
<i>4</i>&nbsp; * Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<i>5</i>&nbsp; * you may not use this file except in compliance with the License.
<i>6</i>&nbsp; * You may obtain a copy of the License at
<i>7</i>&nbsp; *
<i>8</i>&nbsp; *      http://www.apache.org/licenses/LICENSE-2.0
<i>9</i>&nbsp; *
<i>10</i>&nbsp; * Unless required by applicable law or agreed to in writing, software
<i>11</i>&nbsp; * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
<i>12</i>&nbsp; * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<i>13</i>&nbsp; * See the License for the specific language governing permissions and
<i>14</i>&nbsp; * limitations under the License.
<i>15</i>&nbsp; */
<i>16</i>&nbsp;package at.schauer.gregor.vienna.serializer.plugin;
<i>17</i>&nbsp;
<i>18</i>&nbsp;import java.util.Collections;
<i>19</i>&nbsp;import java.util.HashSet;
<i>20</i>&nbsp;import java.util.Map;
<i>21</i>&nbsp;import java.util.Set;
<i>22</i>&nbsp;
<i>23</i>&nbsp;/**
<i>24</i>&nbsp; * @author Gregor Schauer
<i>25</i>&nbsp; */
<i>26</i>&nbsp;public abstract class AbstractPhasePlugin&lt;T&gt; implements SerializerPlugin&lt;T&gt; {
<b class="fc"><i>27</i>&nbsp;	public static enum Phase {</b>
<b class="fc"><i>28</i>&nbsp;		preConstruct, postConstruct, postInitialize, preDeconstruct, postDeconstruct, postFinalize</b>
<i>29</i>&nbsp;	}
<i>30</i>&nbsp;
<b class="fc"><i>31</i>&nbsp;	public Set&lt;Phase&gt; phases = new HashSet&lt;Phase&gt;();</b>
<i>32</i>&nbsp;
<b class="fc"><i>33</i>&nbsp;	public AbstractPhasePlugin(Phase... phases) {</b>
<b class="fc"><i>34</i>&nbsp;		Collections.addAll(this.phases, phases);</b>
<b class="fc"><i>35</i>&nbsp;	}</b>
<i>36</i>&nbsp;
<i>37</i>&nbsp;	protected abstract &lt;E extends T&gt; Map&lt;String, Object&gt; process(Map&lt;String, Object&gt; map, Class&lt;E&gt; clazz);
<i>38</i>&nbsp;
<i>39</i>&nbsp;	protected abstract &lt;E extends T&gt; E process(E obj, Map&lt;String, Object&gt; map);
<i>40</i>&nbsp;
<i>41</i>&nbsp;	@Override
<i>42</i>&nbsp;	public Map&lt;String, Object&gt; preConstruct(Map&lt;String, Object&gt; map, Class&lt;? extends T&gt; clazz) {
<b class="fc"><i>43</i>&nbsp;		return phases.contains(Phase.preConstruct) ? process(map, clazz) : map;</b>
<i>44</i>&nbsp;	}
<i>45</i>&nbsp;
<i>46</i>&nbsp;	@Override
<i>47</i>&nbsp;	public &lt;E extends T&gt; E postConstruct(Map&lt;String, Object&gt; map, E obj) {
<b class="fc"><i>48</i>&nbsp;		return phases.contains(Phase.postConstruct) ? process(obj, map) : obj;</b>
<i>49</i>&nbsp;	}
<i>50</i>&nbsp;
<i>51</i>&nbsp;	@Override
<i>52</i>&nbsp;	public &lt;E extends T&gt; E postInitialize(Map&lt;String, Object&gt; map, E obj) {
<b class="fc"><i>53</i>&nbsp;		return phases.contains(Phase.postInitialize) ? process(obj, map) : obj;</b>
<i>54</i>&nbsp;	}
<i>55</i>&nbsp;
<i>56</i>&nbsp;	@Override
<i>57</i>&nbsp;	@SuppressWarnings(&quot;unchecked&quot;)
<i>58</i>&nbsp;	public Map&lt;String, Object&gt; preDeconstruct(Map&lt;String, Object&gt; map, T obj) {
<b class="fc"><i>59</i>&nbsp;		return phases.contains(Phase.preDeconstruct) ? process(map, (Class&lt;? extends T&gt;) obj.getClass()) : map;</b>
<i>60</i>&nbsp;	}
<i>61</i>&nbsp;
<i>62</i>&nbsp;	@Override
<i>63</i>&nbsp;	@SuppressWarnings(&quot;unchecked&quot;)
<i>64</i>&nbsp;	public Map&lt;String, Object&gt; postDeconstruct(Map&lt;String, Object&gt; map, T obj) {
<b class="fc"><i>65</i>&nbsp;		return phases.contains(Phase.postDeconstruct) ? process(map, (Class&lt;? extends T&gt;) obj.getClass()) : map;</b>
<i>66</i>&nbsp;	}
<i>67</i>&nbsp;
<i>68</i>&nbsp;	@Override
<i>69</i>&nbsp;	@SuppressWarnings(&quot;unchecked&quot;)
<i>70</i>&nbsp;	public Map&lt;String, Object&gt; postFinalize(Map&lt;String, Object&gt; map, T obj) {
<b class="fc"><i>71</i>&nbsp;		return phases.contains(Phase.postFinalize) ? process(map, (Class&lt;? extends T&gt;) obj.getClass()) : map;</b>
<i>72</i>&nbsp;	}
<i>73</i>&nbsp;
<i>74</i>&nbsp;	public Set&lt;Phase&gt; getPhases() {
<b class="fc"><i>75</i>&nbsp;		return phases;</b>
<i>76</i>&nbsp;	}
<i>77</i>&nbsp;
<i>78</i>&nbsp;	public void setPhases(Set&lt;Phase&gt; phases) {
<b class="fc"><i>79</i>&nbsp;		this.phases = phases;</b>
<b class="fc"><i>80</i>&nbsp;	}</b>
<i>81</i>&nbsp;}
</div>
</div>

<div class="footer">
    
    <div style="float:right;">generated on 2012-07-17 20:23</div>
</div>
</body>
</html>
